package com.ctk.wifi.a.net;


import com.ctk.wifi.R;
import com.ctk.wifi.a.net.UDPSocketActivity;


import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class UDPActivity extends Activity {
	//控件
	private EditText mModuleInputField = null;
	private EditText mIpaddrInputField = null;
	private EditText mPortInputField = null;
	private Button mEnterTcpButton = null;
	
	//变量
	private String ModuleInput = null;
	private String IpaddrInput = null;
	private String PortInput = null;
    
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.ctk_ip_configration);
        
    	/**
    	 * Initialise all view components from xml
    	 */        
        mModuleInputField = (EditText)findViewById(R.id.config_module_label_input);
        mIpaddrInputField = (EditText)findViewById(R.id.config_tcp_ipaddr_input);
        mPortInputField = (EditText)findViewById(R.id.config_tcp_port_input);
        mEnterTcpButton = (Button) findViewById(R.id.connect_ip_enter_button);
		
		/**
		 * 响应botton点击动作
		 */
		mEnterTcpButton.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {
		        // 获取IP配置值
				ModuleInput = mModuleInputField.getText().toString().trim();
				IpaddrInput = mIpaddrInputField.getText().toString().trim();
				PortInput = mPortInputField.getText().toString().trim();
				if (ModuleInput.length() == 0) {
					ModuleInput = "CTK-8888";
				}
				if (IpaddrInput.length() == 0) {
					IpaddrInput = "192.168.1.12";
				}
				if (PortInput.length() == 0) {
					PortInput = "6001";
				}
				//创建一个Bundle对象，存入数据
				Bundle bundle = new Bundle();
				bundle.putString("IpaddrInput", IpaddrInput);
				bundle.putString("PortInput", PortInput);
				//创建一个Intent，指定传递和跳转意图
				Intent intent = new Intent();
				intent.putExtras(bundle);
				intent.setClass(UDPActivity.this, UDPSocketActivity.class);
				//启动Activity
				startActivity(intent);
			}
		});
    }
}


